// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
#include "SCustomList.generated.h"


class SSlider;
class SProgressBar;

namespace Plugin_List
{
	class SCollisionScrollBox_List;
}

USTRUCT(BlueprintType)
struct FCustomListInfo
{
	GENERATED_BODY()
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OneInfo)
	float OneValue;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = TwoInfo)
	float TwoValue;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ThreeInfo)
	float ThreeValue;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = FourInfo)
	float FourValue;
};

class STextBlock_TextStyleLambda_List;
/**
 * 
 */
class LISTLIBRARY_API SCustomList : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(SCustomList)
	:_Title("")
	,_TitleStrStyle("AlibabaRegular_12_83AAD6FF")
	,_ColorOneInfo("")
	,_ColorTwoInfo("")
	,_ColorThreeInfo("")
	,_ColorFourInfo("")
	{}
	SLATE_ARGUMENT(FString, Title)
	SLATE_ARGUMENT(FString, TitleStrStyle)
	SLATE_ARGUMENT(FString, ColorOneInfo)
	SLATE_ARGUMENT(FString, ColorTwoInfo)
	SLATE_ARGUMENT(FString, ColorThreeInfo)
	SLATE_ARGUMENT(FString, ColorFourInfo)
	SLATE_END_ARGS()

	virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
	SCustomList();
	/** Constructs this widget with InArgs */
	void Construct(const FArguments& InArgs);
	//更新数据表
	void UpDataList(TMap<FString,FCustomListInfo> InListData);
	//自适应宽度数据表
	void UpdataCustomList();
	//带滚动条的自适应宽度数据表
	void ScrollUpdataCustomList(int width);
	//更改标题名字
	void UpDataTitleName(const FString InTitleName);
	void UpDataOneInfoName(const FString InOneInfoName);
	void UpDataTwoInfoName(const FString InTwoInfoName);
	void UpDataThreeInfoName(const FString InThreeInfoName);
	void UpDataFourInfoName(const FString InFourInfoName);
	void CleanList();
	void Intervalmapping();
	void UpdataMinMaxValue();
	//计算精确小数点后几位
	int FloatAccuracy(int &MaxLen);
	//保留精确度多余的部分进行剔除
	FString GetFloatAccuracy(float Value,int Accuracy);
public:
	virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
	virtual FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) override;
	virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
	virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
public:
	//显示标题的字符串
	TSharedPtr<STextBlock_TextStyleLambda_List> TitleText;
	TSharedPtr<STextBlock_TextStyleLambda_List> OneInfo;
	TSharedPtr<STextBlock_TextStyleLambda_List> TwoInfo;
	TSharedPtr<STextBlock_TextStyleLambda_List> ThreeInfo;
	TSharedPtr<STextBlock_TextStyleLambda_List> FourInfo;
	
	TSharedPtr <SProgressBar> ProgressBar;
	TSharedPtr<SSlider> Slider;
	//是表格内容部分
	TSharedPtr<SBox> ListContent;
	TSharedPtr<Plugin_List::SCollisionScrollBox_List> ZhuScroll;
	TSharedPtr<Plugin_List::SCollisionScrollBox_List> TextScroll;
	//列表中所展示的数据
	TMap<FString, FCustomListInfo> ListData;
public:
	//自定义的数值峰值
	float MaxValue;
	//自定义的数值谷值
	float MinValue;
	//区间
	float GrowValue;
	//柱子的个数
	int PillarNum;
	//柱子背景
	bool PillarBg;
	//警戒值
	float WarningValue;
	//显示警戒线
	bool ShowWarningLine;
	//显示折线
	bool ShowZheLine;
	//显示圆球
	bool ShowYuan;
	//显示标题
	bool ShowTitle;
	//表格宽度
	int32 TableWidth;
	//存放折线的坐标点
	TArray<TSharedPtr<SImage>> YuanImageS;
};